var e = require("../../../../@babel/runtime/helpers/typeof"), t = require("../uni-data-pickerview/uni-data-picker.js"), n = require("../../../../common/vendor.js"), i = {
    name: "UniDataPicker",
    emits: [ "popupopened", "popupclosed", "nodeclick", "input", "change", "update:modelValue", "inputclick" ],
    mixins: [ t.dataPicker ],
    components: {
        DataPickerView: function() {
            return "../uni-data-pickerview/uni-data-pickerview.js";
        }
    },
    props: {
        options: {
            type: [ Object, Array ],
            default: function() {
                return {};
            }
        },
        popupTitle: {
            type: String,
            default: "请选择"
        },
        placeholder: {
            type: String,
            default: "请选择"
        },
        heightMobile: {
            type: String,
            default: ""
        },
        readonly: {
            type: Boolean,
            default: !1
        },
        clearIcon: {
            type: Boolean,
            default: !0
        },
        border: {
            type: Boolean,
            default: !0
        },
        split: {
            type: String,
            default: "/"
        },
        ellipsis: {
            type: Boolean,
            default: !0
        }
    },
    data: function() {
        return {
            isOpened: !1,
            inputSelected: []
        };
    },
    created: function() {
        var e = this;
        this.$nextTick(function() {
            e.load();
        });
    },
    watch: {
        localdata: {
            handler: function() {
                this.load();
            },
            deep: !0
        }
    },
    methods: {
        clear: function() {
            this._dispatchEvent([]);
        },
        onPropsChange: function() {
            this._treeData = [], this.selectedIndex = 0, this.load();
        },
        load: function() {
            var e = this;
            this.readonly ? this._processReadonly(this.localdata, this.dataValue) : this.isLocalData ? (this.loadData(), 
            this.inputSelected = this.selected.slice(0)) : (this.isCloudDataList || this.isCloudDataTree) && (this.loading = !0, 
            this.getCloudDataValue().then(function(t) {
                e.loading = !1, e.inputSelected = t;
            }).catch(function(t) {
                e.loading = !1, e.errorMessage = t;
            }));
        },
        show: function() {
            var e = this;
            this.isOpened = !0, setTimeout(function() {
                e.$refs.pickerView.updateData({
                    treeData: e._treeData,
                    selected: e.selected,
                    selectedIndex: e.selectedIndex
                });
            }, 200), this.$emit("popupopened");
        },
        hide: function() {
            this.isOpened = !1, this.$emit("popupclosed");
        },
        handleInput: function() {
            this.readonly ? this.$emit("inputclick") : this.show();
        },
        handleClose: function(e) {
            this.hide();
        },
        onnodeclick: function(e) {
            this.$emit("nodeclick", e);
        },
        ondatachange: function(e) {
            this._treeData = this.$refs.pickerView._treeData;
        },
        onchange: function(e) {
            var t = this;
            this.hide(), this.$nextTick(function() {
                t.inputSelected = e;
            }), this._dispatchEvent(e);
        },
        _processReadonly: function(t, n) {
            var i;
            if (t.findIndex(function(e) {
                return e.children;
            }) > -1) return Array.isArray(n) ? (i = n[n.length - 1], "object" == e(i) && i.value && (i = i.value)) : i = n, 
            void (this.inputSelected = this._findNodePath(i, this.localdata));
            if (this.hasValue) {
                for (var a = [], o = 0; o < n.length; o++) {
                    var l = n[o], r = t.find(function(e) {
                        return e.value == l;
                    });
                    r && a.push(r);
                }
                a.length && (this.inputSelected = a);
            } else this.inputSelected = [];
        },
        _filterForArray: function(e, t) {
            for (var n = [], i = 0; i < t.length; i++) {
                var a = t[i], o = e.find(function(e) {
                    return e.value == a;
                });
                o && n.push(o);
            }
            return n;
        },
        _dispatchEvent: function(e) {
            var t = {};
            if (e.length) {
                for (var n = new Array(e.length), i = 0; i < e.length; i++) n[i] = e[i].value;
                t = e[e.length - 1];
            } else t.value = "";
            this.formItem && this.formItem.setValue(t.value), this.$emit("input", t.value), 
            this.$emit("update:modelValue", t.value), this.$emit("change", {
                detail: {
                    value: e
                }
            });
        }
    }
};

Array || (n.resolveComponent("uni-load-more") + n.resolveComponent("uni-icons") + n.resolveComponent("data-picker-view"))(), 
Math || (function() {
    return "../../../uni-load-more/components/uni-load-more/uni-load-more.js";
} + function() {
    return "../../../uni-icons/components/uni-icons/uni-icons.js";
})();

var a = n._export_sfc(i, [ [ "render", function(e, t, i, a, o, l) {
    return n.e({
        a: e.errorMessage
    }, e.errorMessage ? {
        b: n.t(e.errorMessage)
    } : e.loading && !o.isOpened ? {
        d: n.p({
            contentText: e.loadMore,
            status: "loading"
        })
    } : o.inputSelected.length ? {
        f: n.f(o.inputSelected, function(e, t, a) {
            return n.e({
                a: n.t(e.text),
                b: t < o.inputSelected.length - 1
            }, t < o.inputSelected.length - 1 ? {
                c: n.t(i.split)
            } : {}, {
                d: t
            });
        })
    } : {
        g: n.t(i.placeholder)
    }, {
        c: e.loading && !o.isOpened,
        e: o.inputSelected.length,
        h: i.clearIcon && !i.readonly && o.inputSelected.length
    }, i.clearIcon && !i.readonly && o.inputSelected.length ? {
        i: n.p({
            type: "clear",
            color: "#c0c4cc",
            size: "24"
        }),
        j: n.o(function() {
            return l.clear && l.clear.apply(l, arguments);
        })
    } : {}, {
        k: !(i.clearIcon && o.inputSelected.length || i.readonly)
    }, (i.clearIcon && o.inputSelected.length || i.readonly, {}), {
        l: i.border ? 1 : "",
        m: n.r("d", {
            options: i.options,
            data: o.inputSelected,
            error: e.errorMessage
        }),
        n: n.o(function() {
            return l.handleInput && l.handleInput.apply(l, arguments);
        }),
        o: o.isOpened
    }, o.isOpened ? {
        p: n.o(function() {
            return l.handleClose && l.handleClose.apply(l, arguments);
        })
    } : {}, {
        q: o.isOpened
    }, o.isOpened ? {
        r: n.t(i.popupTitle),
        s: n.o(function() {
            return l.handleClose && l.handleClose.apply(l, arguments);
        }),
        t: n.sr("pickerView", "ae2d9350-2"),
        v: n.o(l.onchange),
        w: n.o(l.ondatachange),
        x: n.o(l.onnodeclick),
        y: n.o(function(t) {
            return e.dataValue = t;
        }),
        z: n.p({
            localdata: e.localdata,
            preload: e.preload,
            collection: e.collection,
            field: e.field,
            orderby: e.orderby,
            where: e.where,
            "step-searh": e.stepSearh,
            "self-field": e.selfField,
            "parent-field": e.parentField,
            "managed-mode": !0,
            map: e.map,
            ellipsis: i.ellipsis,
            modelValue: e.dataValue
        })
    } : {});
} ] ]);

wx.createComponent(a);